SET(GAMCS_GAM_SRCS
    ./GIOM.cpp
    ./TSGIOM.cpp
    ./StateInfoParser.cpp
    ./Agent.cpp
    ./Avatar.cpp
    )

SET(GAMCS_CS_SRCS
    ./CSOSAgent.cpp
    ./PrintViewer.cpp
    ./DotViewer.cpp
    ./CDotViewer.cpp
    ./debug.cpp
    ./platforms.cpp
    )

SET(GAMCS_LIB_SRCS ${GAMCS_GAM_SRCS} ${GAMCS_CS_SRCS})

SET(GAMCS_MYSQL_SRCS
    ./Mysql.cpp
    )

IF (MYSQL_FOUND)
    SET(GAMCS_LIB_SRCS
        ${GAMCS_LIB_SRCS}
        ${GAMCS_MYSQL_SRCS}
        )
ENDIF()

SET(GAMCS_SQLITE_SRCS
    ./Sqlite.cpp
    )

IF (SQLITE3_FOUND)
    SET(GAMCS_LIB_SRCS
        ${GAMCS_LIB_SRCS}
        ${GAMCS_SQLITE_SRCS}
        )
ENDIF()

# version resource for windows
IF (WIN32)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/winver.rc.in ${CMAKE_CURRENT_BINARY_DIR}/winver.rc)
ENDIF (WIN32)

# shared library
IF (WIN32)
ADD_LIBRARY(${GAMCS_NAME} SHARED ${GAMCS_LIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/winver.rc)  # add version resource for windows
ELSE (WIN32)
ADD_LIBRARY(${GAMCS_NAME} SHARED ${GAMCS_LIB_SRCS})
ENDIF (WIN32)
TARGET_LINK_LIBRARIES(${GAMCS_NAME} ${LIBS})   # dependencies
SET_TARGET_PROPERTIES(${GAMCS_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1 
    VERSION ${GAMCS_MAJOR}.${GAMCS_MINOR} SOVERSION ${GAMCS_MAJOR})

# static library
IF(WIN32)
ADD_LIBRARY(${GAMCS_STATIC_NAME} STATIC ${GAMCS_LIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/winver.rc)  # add version resource for windows
ELSE (WIN32)
ADD_LIBRARY(${GAMCS_STATIC_NAME} STATIC ${GAMCS_LIB_SRCS})
ENDIF (WIN32)
TARGET_LINK_LIBRARIES(${GAMCS_STATIC_NAME} ${LIBS})
SET_TARGET_PROPERTIES(${GAMCS_STATIC_NAME} PROPERTIES OUTPUT_NAME ${GAMCS_NAME} CLEAN_DIRECT_OUTPUT 1)

# install library
SET(LIBDIR  ${CMAKE_INSTALL_PREFIX}/lib)
INSTALL(TARGETS ${GAMCS_NAME} ${GAMCS_STATIC_NAME}
    LIBRARY DESTINATION ${LIBDIR}
    ARCHIVE DESTINATION ${LIBDIR})
